package com.wing.member.feign;

import com.wing.common.utils.JsonResult;
import com.wing.member.model.response.MemberAuthVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * 调用用户中心中的userdetail对象，用户oauth中的登录
 * 获取的用户与页面输入的密码 进行BCryptPasswordEncoder匹配
 *
 * @author
 */
@FeignClient(name = "member-server", fallback = MemberClientFallback.class)
public interface MemberClient {

    /**
     * 通过用户名找到用户
     *
     * @param username 用户名
     * @return {@link MemberAuthVO}
     */
    @GetMapping(value = "/member/admin/member/getByUsername", params = "username")
    JsonResult<MemberAuthVO> findMemberByUsername(@RequestParam("username") String username);

    /**
     * 通过手机号找到用户
     *
     * @param phone 手机号
     * @return {@link MemberAuthVO}
     */
    @GetMapping(value = "/member/admin/member/getByPhone", params = "phone")
    JsonResult<MemberAuthVO> findMemberByPhone(@RequestParam("phone") Long phone);

    /**
     * 通过openId找到用户
     *
     * @param openId openId
     * @return {@link MemberAuthVO}
     */
    @GetMapping(value = "/member/admin/member/getByOpenId", params = "openId")
    JsonResult<MemberAuthVO> findMemberByOpenId(@RequestParam("username") String openId);

}
